package com.pos.clothes.controller;

import com.pos.clothes.service.ReportService;
import com.pos.clothes.service.SizeService;
import com.pos.clothes.util.JsonData;
import com.pos.clothes.util.MyDate;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
@RequiresPermissions("2")
@RequestMapping("/Report")
public class ReportController {
    @Autowired
    public ReportService service;
    @ResponseBody
    @RequestMapping("/salemounth")
    public Object getAllOrder(@RequestParam String yue){
        String s = MyDate.tranMyDate(yue);
        if(s==null){return JsonData.buildError("输入的月份有误");}
        return JsonData.buildSuccess(service.getAllOrderAboutDate(s),yue+"月的每天的销售金额");
    }

    @ResponseBody
    @RequestMapping("/saleyear")
    public Object getAllOrdermonth(@RequestParam String nian){

        if(nian==null||Integer.valueOf(nian)<=0||Integer.valueOf(nian)>2021){return JsonData.buildError("输入的年份有误");}
        return JsonData.buildSuccess(service.getALLOrderAboutMonth(nian),nian+"年的每月的销售金额");
    }

    @ResponseBody
    @RequestMapping("/amountclass")
    public Object getAllOrder(){
        return service.getCategoryInsituation();
    }

}
